#ifndef  SHINY_UI_HPP
# define SHINY_UI_HPP

# include "container.hpp"
# include "datatree.hpp"
# include "texturelist.hpp"

namespace Shiny
{
  namespace Widgets
  {
    class Ui : public Container
    {
      friend class Container;
    public:
      Ui(TextureList* tm, AnimationList* am) : _textureManager(tm), _animationManager(am)
      {
	  _ownTextureList   = false;
	  _ownAnimationList = false;
	  _typeCode         = Shiny::Widgets::WidgetUi;
      }

      Ui(Data, TextureList* tm = 0, AnimationList* am = 0);
      
      ~Ui(void);

      void               Render(sf::RenderTarget&);
      TextureList*       GetTextureList(void)   { return (_textureManager);   }
      AnimationList*     GetAnimationList(void) { return (_animationManager); }

    private:
      struct type2builder
      {
        const std::string key;
        Container*        (Ui::*function)(Data);
      };

      void               GenerateFromFile(Data, Container* father = 0);
      static sf::Color   GetColor(Data);
      static void        GenerateMouseAwareness(Data, unsigned char& flag);
      static void        GeneratePadding(Data h, Data v, sf::Vector2f&, bool);
      static void        GenerateAlign(Data h, Data v, AlignType&, VAlignType&);
      static void        GenerateAnimation(Data data, Container*);
      Container*         BuildUi(Data);
      Container*         BuildTextWidget(Data);
      Container*         BuildProgressBar(Data);
      Container*         BuildList(Data);

      static type2builder _type2builders[];
      TextureList*        _textureManager;
      AnimationList*      _animationManager;
      bool                _ownTextureList, _ownAnimationList;
    };
  }
}

#endif
